package net.uhuijia.goods.skupropertyvalue.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import net.uhuijia.appbase.controller.BaseController;
import net.uhuijia.constants.DBConst;
import net.uhuijia.goods.skupropertyvalue.persistence.model.SkuPropertyValue;
import net.uhuijia.goods.skupropertyvalue.persistence.model.SkuPropertyValueExample;
import net.uhuijia.goods.skupropertyvalue.persistence.model.SkuPropertyValueExample.Criteria;
import net.uhuijia.goods.skupropertyvalue.service.SkuPropertyValueService;
import net.uhuijia.utils.StringHelper;
import net.uhuijia.vo.ResultMapVo;
import net.uhuijia.vo.ReturnListVo;


@RestController
@RequestMapping(value="/skupropertyvalue")
public class SkuPropertyValueController
     extends BaseController<SkuPropertyValueService,SkuPropertyValue,SkuPropertyValueExample> {
	
	private SkuPropertyValueService skuPropertyValueService;
	@Autowired
	public void setUserMallService(SkuPropertyValueService skuPropertyValueService) {
		this.skuPropertyValueService = skuPropertyValueService;
	}
	
	/**
	 * 获取分类 集合 (根据父类codeId)
	 * @author 王文鑫  
	 * @date 2018年9月29日  
	 * @return
	 */
	@RequestMapping(value = "/getList", method = RequestMethod.GET)
	@ResponseBody
	public ResultMapVo<ReturnListVo<SkuPropertyValue>> getList(String nameId) {
		
		ReturnListVo<SkuPropertyValue> returnListVos = null;
		
		if(StringHelper.isEmpty(nameId)){
			throw new IllegalArgumentException();//参数异常			
		}else{
			SkuPropertyValueExample example = new SkuPropertyValueExample();
			Criteria criteria = example.createCriteria();
			criteria.andIsEffectiveEqualTo(DBConst.TRUE);
			criteria.andPropertyNameIdEqualTo(nameId);
			List<SkuPropertyValue> skuPropertyValueList = skuPropertyValueService.list(example);
			returnListVos = new ReturnListVo<>(skuPropertyValueList);
		}
		return ResultMapVo.ok(returnListVos);
	}
}